<?php
	
	/**
	 * @see Zend_Validate_Abstract
	 */
	require_once 'Zend/Validate/Abstract.php';
	
	
	class Zend_Validate_Number extends Zend_Validate_Abstract
	{
	    const NOT_NUMBER   = 'notNumber';
	    const STRING_EMPTY = 'numberStringEmpty';
	    const INVALID   = 'regexInvalid';

	    protected $_messageTemplates = array(
	        self::NOT_NUMBER   => "'%value%' must contain only digits and '-'",
	        self::STRING_EMPTY => "'%value%' is an empty string",
	        self::INVALID      => "Invalid type given. String, integer or float expected",
	    );

	    protected $_pattern = '/^\-?\d+(\.?\d+)?$/';

		public function isValid($value)
	    {
	        if(!is_string($value) && !is_int($value) && !is_float($value))
	        {
	            $this->_error(self::INVALID);
	            return false;
	        }

	        $this->_setValue($value);

	        if('' === $this->_value)
	        {
	            $this->_error(self::STRING_EMPTY);
	            return false;
	        }

	        $status = @preg_match($this->_pattern, $value);
	        if(false === $status)
	        {
	            $this->_error(self::ERROROUS);
	            return false;
	        }

	        if(!$status)
	        {
	            $this->_error(self::NOT_NUMBER);
	            return false;
	        }

	        return true;
	    }
	}
